package com.itheima.chapter01.method;
/*
    方法同时获取最大值最小值
 */
public class demo {
    public static void main(String[] args) {
        int arr[]={11,22,33,44,55,66,77};
        int[] result=getMinAndMax(arr);
        System.out.println("min值"+result[0]);
        System.out.println("max值"+result[1]);

    }
    public static int[] getMinAndMax(int arr[]){
        int max=arr[0];
        int min=arr[0];
        for (int i = 0; i <arr.length ; i++) {
            if(max<arr[i]){
                max=arr[i];
            }
            if(min>arr[i]){
                min=arr[i];
            }
        }
        int array[]={min,max};
        return array;
    }
}
